﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TZReport_Service.Config;
using TZReport_Service.TZService;
using TZReport_Util.Model;
using TZRerport_Dal.YY;

namespace TZ_Report_UploadWebApi.Controllers.API
{
    [RoutePrefix("api/ReportUpload")]
    public class ReportUploadController : ApiController
    {
        private TZReportService TZReportService = new TZReportService(HospitalConfigManager.isql);

        [HttpGet, Route("GetToken")]
        public ResultInfo GetToken()
        {
            string token = string.Empty;
            ResultInfo res = TZReportService.GetToken(out token);
            res.data = new { token = token};
            return res;
        }

        [HttpGet, Route("UpReplaceEmpty")]
        public ResultInfo UpReplaceEmpty()
        {
            ResultInfo res = TZReportService.UpReplaceEmpty();
            return res;
        }

        [HttpGet,Route("InitRecord")]
        public ResultInfo InitRecord()
        {
            ResultInfo res = TZReportService.InitRecord();
            return res;
        }

        [HttpGet, Route("EditFileName")]
        public ResultInfo EditFileName()
        {
            ResultInfo res = TZReportService.EditFileName();
            return res;
        }

        [HttpGet, Route("EditRecordPDF")]
        public ResultInfo EditRecordPDF()
        {
            ResultInfo res = TZReportService.EditRecordPDF();
            return res;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        [HttpGet, Route("InitRecordForNum")]
        public ResultInfo InitRecordForNum(int num)
        {
            ResultInfo res = TZReportService.InitRecord(num);
            return res;
        }

        /// <summary>
        /// 自动传输
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("AutoUpLoad")]
        public ResultInfo AutoUpLoad()
        {
            ResultInfo res = TZReportService.AutoUpLoad();
            return res;
        }

        [HttpGet, Route("GetPDFBase64")]
        public ResultInfo GetPDFBase64(string tjh)
        {
            return TZReportService.GetPDFBase64(tjh);
        }

        /// <summary>
        /// 手动传输
        /// </summary>
        /// <param name="tjh"></param>
        /// <returns></returns>
        [HttpGet, Route("ManualUpload")]
        public ResultInfo ManualUpload(string tjh)
        {
            ResultInfo res = TZReportService.ManualUpload(tjh);
            return res;
        }

        [HttpGet, Route("RetryReportUpload")]
        public ResultInfo RetryReportUpload(string tjh)
        {
            ResultInfo res = TZReportService.RetryReportUpload(tjh);
            return res;
        }

        /// <summary>
        /// 登记上传
        /// </summary>
        /// <param name="tjh"></param>
        /// <returns></returns>
        [HttpGet, Route("ManualDengJiUpLoad")]
        public ResultInfo ManualDengJiUpLoad(string tjh)
        {
            ResultInfo res = TZReportService.ManualDengJiUpLoad(tjh);
            return res;
        }

        /// <summary>
        /// pdf上传
        /// </summary>
        /// <param name="tjh"></param>
        /// <returns></returns>
        [HttpGet, Route("ManualPDFUpLoad")]
        public ResultInfo ManualPDFUpLoad(string tjh)
        {
            ResultInfo res = TZReportService.ManualPDFUpLoad(tjh);
            return res;
        }
    }
}
